package util;

import java.util.Date;

public class DateUtil {
	public static String getDateStr(Date date){
		String str = (1900 + date.getYear()) + "-" + (date.getMonth()+1) + "-" + date.getDate() + "-" + date.getHours();
		return str;
	}
	
	public static Date getDate(int year, int month, int day, int hour) {
		Date date = new Date();
		date.setYear(year-1900);
		date.setMonth(month-1);
		date.setDate(day);
		date.setHours(hour);
		return date;
	}
	
	public static String getNewsDateStr(Date date){
		String str = (1900 + date.getYear()) + "-" + (date.getMonth()+1) + "-" + date.getDate();
		return str;
	}
	
	public static String[] getDateStrs(Date startDate, int offset){
		String[] str = new String[offset];
		int i = offset;
		while(i > 0){
			Date date = new Date(startDate.getYear(),startDate.getMonth(), startDate.getDate() - (offset - i));
			String datestr = (1900 + date.getYear()) + "-" + (date.getMonth()+1) + "-" + date.getDate();
			str[i-1] = datestr;
			i--;
		}
		return str;
	}
	
	public static void main(String[] args) {
		String[] s = DateUtil.getDateStrs(new Date(),365);
		for(String t : s)
			System.out.println(t);
	}
}
